package com.junqi.common.entity;

import cn.hutool.core.util.StrUtil;

public class RedisKeyManager {
    // Prefix 常量初始开头
    private static final String PREFIX = "jq";

    // 统一分隔符，便于分隔命名空间
    private static final String DELIMITER = ":";

    /**
     * 登录验证码
     */
    public static final String LOGIN_CODE= "loginCode";


    /**
     * 用户key
     */
    public static final String USER= "user";

    /**
     * 用户角色key
     */
    public static final String USER_ROLE= USER+DELIMITER+"role";

    /**
     * 用户信息key
     */
    public static final String USER_INFO= USER+DELIMITER+"info";


    /**
     * 房间key
     */
    public static final String ROOM= "room";

    /**
     * 房间消息key
     */
    public static final String ROOM_MSG = ROOM+DELIMITER+"msg";

    /**
     * 房间用户key
     */
    public static final String ROOM_USERS = ROOM+DELIMITER+"users";

    /**
     * 房间自增消息id
     */
    public static final String ROOM_MSG_ID = ROOM_MSG+DELIMITER+"id";

    /**
     * 根据房间限流
     */
    public static final String ROOM_RATE_LIMIT = ROOM+DELIMITER+"rate_limit";


    /**
     * websocket待通知队列的用户id
     */
    public static final String WS_NOTIF_QUEUE_USERS = "ws_notif_queue_users";


    /**
     * 通用自定义 Key 生成方法
     *
     * @param components Key 的组件
     * @return 拼接后的 Redis Key
     */
    public static String generateKey(String... components) {
        return StrUtil.join(DELIMITER, PREFIX,components);
    }
}
